home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Files / ficycle / ficycle.Pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-15  |  2.8 KB  |  86 lines  |  [TEXT/TPAS]

  1. PROGRAM ficycle;
  2. (*                                                                                              *)
  3. (*  1.0     11/89    ZZ Zimmerman                                                                *)
  4.  
  5. {$U+}
  6.  
  7. USES Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf, MacPrint;
  8.  
  9. VAR
  10.    targetVolume:     INTEGER;
  11.    targetFileName:   Str255;
  12.    theIOParams:      ParamBlockRec;
  13.    theError:         OSErr;
  14.  
  15. PROCEDURE Debugger; INLINE $A9FF;
  16.  
  17. (* Use Standard File to get and open a file to be printed. *)
  18. FUNCTION GetVolume(VAR vRefNum: INTEGER): BOOLEAN;
  19. CONST
  20.    numTypes =  1;
  21. VAR
  22.    theReply:      SFReply;
  23.    theTypes:      SFTypeList;
  24.    theTopLeft:    Point;
  25.    theError:      OSErr;
  26. BEGIN
  27.    SetPt(theTopLeft, 100, 100);
  28.    SFGetFile(theTopLeft, '', NIL, 0, theTypes, NIL, theReply);
  29.    vRefNum := theReply.vRefNum;
  30.    GetVolume := theReply.good;
  31. END;
  32.  
  33.  
  34. BEGIN
  35. (*      InitGraf(@thePort);
  36.       InitFonts;
  37.       FlushEvents(everyEvent, 0);
  38.       InitWindows;
  39.       InitMenus; *)
  40.       TEInit;
  41.       InitDialogs(NIL);
  42.       InitCursor;
  43.  
  44.    (* Start by calling SFGetFile to allow the user to choose a folder.  *)
  45.       IF GetVolume(targetVolume) THEN BEGIN
  46.       (* If we got one, now we need to call SetVol to select the        *)
  47.       (* folder.  Although the name SetVol implies that only a volume   *)
  48.       (* can be set, SetVol is smart enough to use a folder as a volume.*)
  49.       theError := SetVol(NIL, targetVolume);
  50.       
  51.       (* Now we want to loop through all of the files in this folder.   *)
  52.       (* We do this by using the extra cool FDirIndex feature of the    *)
  53.       (* File Manager's parameter block calls.                          *)
  54.       theIOParams.ioFDirIndex := 1;
  55.       
  56.       (* When we run out of files, GetFInfo will return an error.       *)
  57.       (* While it returns noErr, we'll keep looping and writing out the *)
  58.       (* name of the file we found.                                     *)
  59.       WHILE theError = noErr DO BEGIN
  60.          
  61.          WITH theIOParams DO BEGIN
  62.             (* The file name (to be filled in by GetFInfo.              *)
  63.             ioNamePtr := @targetFileName;
  64.             
  65.             (* The volume reference number that we got from SFGetFile.  *)
  66.             ioVRefNum := targetVolume;
  67.             
  68.             (* Version number should always be zero.                    *)
  69.             ioVersNum := 0;
  70.          END;
  71.          
  72.          (* Okay, now try to get information about this file.           *)
  73.          theError := PBGetFInfo(@theIOParams, FALSE);
  74.          
  75.          (* If we got the info, write out the file's name.              *)
  76.          IF theError = noErr THEN WRITELN(targetFileName);
  77.          
  78.          (* Increment to the next file in the folder (if any).          *)
  79.          theIOParams.ioFDirIndex := theIOParams.ioFDirIndex + 1;
  80.       END;
  81.       END;
  82.   
  83.   (* Give the user a chance to see what's going on.   *)
  84.   WHILE NOT Button DO ;
  85. END.
  86.